<extend name="Public/base"/>

<block name="body">
    
     <div class="col-sm-12">
         <div class="tabbable">
             <ul class="nav nav-tabs" id="myTab">
                 <li class="active">
                 <a data-toggle="tab" href="javascript:;">
                     		采集商品
                 </a>
                 </li>
             </ul>

             <div class="tab-content">
                 <div id="home" class="tab-pane in active">

                    <form class="form-horizontal" role="form" action="{:U('Collect/index')}" method="post" enctype="multipart/form-data">
                         <div class="form-group">
                             <label class="col-sm-2 control-label no-padding-right" for="form-field-1">采集规则名称<span style="color:#f00;"></span></label>
                             <div class="col-sm-9"><input class="col-sm-12 form-control" name="name" type="text" value="{$rule['name']}"></div>
                         </div>
                         <div class="form-group">
                             <label class="col-sm-2 control-label no-padding-right" for="form-field-1">关键字<span style="color:#f00;">*</span></label>
                             <div class="col-sm-9"><input class="col-sm-12 form-control" name="q" type="text" value="{$rule['q']}"></div>
                         </div>

                         <div class="form-group">
                             <label class="col-sm-2 control-label no-padding-right" for="form-field-1">API-CID<span style="color:#f00;">*</span></label>
                             <div class="col-sm-9"><input class="col-sm-12 form-control" placeholder="关键词填写后此项可不填" name="cid"  value="{$rule['cid']}" type="text"></div>
                         </div>

                         <div class="form-group">
                             <label class="col-sm-2 control-label no-padding-right">所属分类</label>
                             <div class="col-sm-9">
                                 <select class="col-sm-12" name="cate_id">
                                    <volist name='category' id='data'>
                                        <option value="{$data['id']}">
                                        	<if condition="$data.pid gt 0">
                                        		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                        	</if>
                                        		{$data['category_name']}</option>
										   		<notempty name="data['_']">
													<volist name="data['_']" id='id'>
													   <option value="{$id['id']}">
													   	<if condition="$id.pid gt 0">
													   		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
													   	</if>	
													   		{$id['category_name']}</option>
													   		<notempty name="id['_']">
																<volist name="id['_']" id='id1'>
																   <option value="{$id1['id']}">
																   	<if condition="$id1.pid gt 0">
																   		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
																   	</if>	
																   		{$id1['category_name']}</option>
																</volist>
															</notempty>
													</volist>
												</notempty>
                                    </volist>  
                                  </select>
                                  <script type='text/javascript'>
                                        $("select[name='cate_id'] option[value='<php>echo $rule[cate_id]</php>']").attr('selected','selected');
                                    </script>
                              </div>
                             
                         </div>

                         <div class="form-group">
                             <label class="col-sm-2 control-label no-padding-right" for="form-field-1">起始价格</label>
                             <div class="col-sm-9"><input class="col-sm-12 form-control" name="start_price" type="text" value="{$rule['start_price']}"></div>
                         </div>


                         <div class="form-group">
                             <label class="col-sm-2 control-label no-padding-right" for="form-field-1">最高价格</label>
                             <div class="col-sm-9"><input class="col-sm-12 form-control" name="end_price" value="{$rule['end_price']}" type="text"></div>
                         </div>


                         <div class="form-group">
                             <label class="col-sm-2 control-label no-padding-right" for="form-field-1">佣金比率下限</label>
                             <div class="col-sm-9"><input class="col-sm-12 form-control" placeholder="1234表示12.34%" name="start_tk_rate" value="{$rule['start_tk_rate']}" type="text"></div>
                         </div>

                         <div class="form-group">
                             <label class="col-sm-2 control-label no-padding-right" for="form-field-1">佣金比率上限</label>
                             <div class="col-sm-9"><input class="col-sm-12 form-control" placeholder="1234表示12.34%" name="end_tk_rate" value="{$rule['end_tk_rate']}"type="text"></div>
                         </div>

                         <div class="form-group">
                             <label class="col-sm-2 control-label no-padding-right">排序方式</label>	
                             <div class="col-sm-9">
                                 <select class="col-sm-12 form-control" name="sort">
                                     <option selected="selected" <if condition="$rule.sort eq 'total_sales_asc'">selected="selected"</if> value="total_sales_desc">销量从高到低</option>
                                     <option value="total_sales_asc" <if condition="$rule.sort eq 'total_sales_asc'">selected="selected"</if>>销量从低到高</option>
                                     <option value="tk_rate_desc" <if condition="$rule.sort eq 'tk_rate_desc'">selected="selected"</if>>佣金比率从高到低</option>
                                     <option value="tk_rate_asc" <if condition="$rule.sort eq 'tk_rate_asc'">selected="selected"</if>>佣金比率从低到高</option>
                                     <option value="tk_total_sales_desc" <if condition="$rule.sort eq 'tk_total_sales_desc'">selected="selected"</if>>累计推广量从高到低</option>
                                     <option value="tk_total_sales_asc" <if condition="$rule.sort eq 'tk_total_sales_asc'">selected="selected"</if>>累计推广量从低到高</option>
                                     <option value="tk_total_commi_desc" <if condition="$rule.sort eq 'tk_total_commi_desc'">selected="selected"</if>>总支出佣金从高到低</option>
                                     <option value="tk_total_commi_asc" <if condition="$rule.sort eq 'tk_total_commi_asc'">selected="selected"</if>>总支出佣金从低到高</option>
                                 </select>
                              </div>
                         </div>
                         <div class="form-group">
                             <label class="col-sm-2 control-label no-padding-right" for="form-field-1">第几页</label>
                             <div class="col-sm-9"><input class="col-sm-12 form-control" placeholder="第几页，默认1" name="page_no" type="text" value="{$rule.page_no}"></div>
                         </div>
                         <div class="form-group">
                             <label class="col-sm-2 control-label no-padding-right" for="form-field-1">每页数量</label>
                             <div class="col-sm-9"><input class="col-sm-12 form-control" placeholder="默认10个，最多100个" name="page_size" type="text" value="{$rule.page_size}"></div>
                         </div>
            
                        

                         <div class="clearfix form-actions">
                             <div class="col-md-offset-4 col-md-4">
                                 <button class="btn btn-info ajax-post" target-form="form-horizontal" url="{:U('update')}">
                                     
                                  		   保存规则
                                 </button>
                                 <button class="btn btn-info" type="submit">
                                     
                                  		   保存规则并采集
                                 </button>
                                 <input type="hidden" name="id" value="{$rule.id}">
                             </div>
                         </div>
                     </form>
                  </div>
             </div>
         </div>
     </div>
                
</block>
    <a href="#" id="btn-scroll-up" class="btn-scroll-up btn btn-sm btn-inverse">
        <i class="icon-double-angle-up icon-only bigger-110"></i>
    </a>
    <style>
        .orange{background:orange;}
    </style>
<script type="text/javascript">
    
    $(function(){
        $("tbody tr").click(function(){
            var obj = $(this);
            if(obj.find('td:first').attr('style')==''){
                obj.find('td').attr('style','background:orange');
            }else{
                obj.find('td').attr('style','');
            }
        });
    });
    (function(win,doc){
        var s = doc.createElement("script"), h = doc.getElementsByTagName("head")[0];
        if (!win.alimamatk_show) {
            s.charset = "utf8";
            s.async = true;
            s.src = "http://a.alimama.cn/tkapi.js";
            h.insertBefore(s, h.firstChild);
        };
        var o = {
            pid: "mm_43412205_9948295_33168978",/*推广单元ID，用于区分不同的推广渠道*/
            appkey: "23189880",/*通过TOP平台申请的appkey，设置后引导成交会关联appkey*/
            unid: "",/*自定义统计字段*/
            type: "click" /* click 组件的入口标志 （使用click组件必设）*/
        };
        win.alimamatk_onload = win.alimamatk_onload || [];
        win.alimamatk_onload.push(o);
    })(window,document);
</script>
